package com.itzsj.service.implement;

import com.itzsj.mapper.AdminMapper;
import com.itzsj.pojo.entity.Enterprise;
import com.itzsj.pojo.entity.Graduate;
import com.itzsj.pojo.entity.Message;
import com.itzsj.pojo.entity.Work;
import com.itzsj.service.AdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

@Slf4j
@Service
public class AdminServiceImpl implements AdminService {

    @Resource
    private AdminMapper adminMapper;

    @Override
    public List<Graduate> listG(String sno, String grade) {
        return adminMapper.listG(sno, grade);
    }

    @Override
    public void updateG(Graduate graduate) {
        log.info("graduate {}", graduate);
        adminMapper.updateG(graduate);
    }

    @Override
    public void deleteG(String sno) {
        adminMapper.deleteG(sno);
        adminMapper.deleteGW(sno);
        adminMapper.deleteGM(sno);
        adminMapper.deleteGP(sno);
    }

    @Override
    public List<Work> listW(String sno) {
        return adminMapper.listW(sno);
    }

    @Override
    public void saveW(Work work) {
        adminMapper.saveW(work);
        adminMapper.changeW(work.getSno(),1);
    }

    @Override
    public void deleteW(String sno) {
        adminMapper.deleteW(sno);
        adminMapper.changeW(sno,null);
    }

    @Override
    public List<Enterprise> listE(String eno) {
        return adminMapper.listE(eno);
    }

    @Override
    public void saveE(Enterprise enterprise) {
        adminMapper.saveE(enterprise);
    }

    @Override
    public void deleteE(String eno) {
        adminMapper.deleteE(eno);
        adminMapper.deleteEJ(eno);
        adminMapper.deleteEM(eno);
        adminMapper.deleteEP(eno);
    }

    @Override
    public List<Message> listM(String sno) {
        return adminMapper.listM(sno);
    }

    @Override
    public void deleteM(List<Integer> ids) {
        adminMapper.deleteM(ids);
    }


}
